<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>下拉菜单</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        #box {
            margin: 0 auto;
        }
        
        li {
            list-style: none;
        }
        
        a {
            text-decoration: none;
            font-size: 16px;
        }
        
        #nav>li {
            float: left;
            display: block;
            width: 150px;
            height: 16px;
            line-height: 16px;
            text-align: center;
            position: relative;
            background-color: #b1b1b1;
        }
        
        #nav li a {
            display: block;
            width: 100%;
            height: 100%;
            color: #131425;
        }
        
        #nav ul {
            display: none;
            position: absolute;
            top: 30px;
            left: 43px;
        }
        
        #nav>li>a:hover {
            background-color: #FFF;
        }
    </style>
</head>

<body>
    <div id="box">
        <ul id="nav">
            <li>
                <a href="">企业采购</a>
                <ul>
                    <li>
                        <a href="">企业够</a>
                    </li>
                    <li>
                        <a href="">礼品卡</a>
                    </li>
                    <li>
                        <a href="">工业品</a>
                    </li>
                </ul>
            </li>
            <li>
                <a href="">客户服务</a>
                <ul>
                    <li>
                        <a href="">在线客服</a>
                    </li>
                    <li>
                        <a href="">电话客服</a>
                    </li>
                    <li>
                        <a href="">意见建议</a>
                    </li>
                </ul>
            </li>
            <li>
                <a href="">网站导航</a>
                <ul>
                    <li>
                        <a href="">特色主题</a>
                    </li>
                    <li>
                        <a href="">行业频道</a>
                    </li>
                    <li>
                        <a href="">生活服务</a>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
</body>

</html>
<script>
    let nav = window.document.querySelector('#nav');
    let lis = nav.children;
    for (let index = 0; index < lis.length; index++) {
        const element = lis[index];
        element.onmouseover = function(params) {
            element.children[1].style.display = 'block';
        };
        element.onmouseout = function(params) {
            element.children[1].style.display = 'none';
        };
    }
</script>